//
//  HHAddBankCardHeaderView.m
//  HHBroker
//
//  Created by He Wei on 10/18/15.
//  Copyright © 2015 harry. All rights reserved.
//

#import "HHAddBankCardHeaderView.h"
#import "UIViewAdditions.h"

@interface HHAddBankCardHeaderView ()

@property (nonatomic, strong) UIButton *statusButton;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UILabel *desLabel;
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;

@end

@implementation HHAddBankCardHeaderView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.statusButton];
        [self addSubview:self.statusLabel];
        [self addSubview:self.desLabel];
        [self addGestureRecognizer:self.tapGesture];
    }
    return self;
}

+ (HHAddBankCardHeaderView *)headerView
{
    return [[HHAddBankCardHeaderView alloc] initWithFrame:CGRectMake(0, 0, kCurrentWidth, 121)];
}

#pragma mark - Event
- (void)tapGesture:(UITapGestureRecognizer *)tap
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(headerViewDidTouched:)]) {
        [self.delegate headerViewDidTouched:self];
    }
}

- (void)addBankCardButtonClicked:(UIButton *)button
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(headerViewDidTouched:)]) {
        [self.delegate headerViewDidTouched:self];
    }
}

#pragma mark - Setter && Getter

- (UIButton *)statusButton
{
    if (_statusButton == nil) {
        _statusButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _statusButton.frame = CGRectMake((self.width-55)/2.0, 20, 55, 40);
        [_statusButton setImage:[UIImage imageNamed:@"button_addBankCard"] forState:UIControlStateNormal];
        [_statusButton addTarget:self action:@selector(addBankCardButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _statusButton;
}

- (UILabel *)statusLabel
{
    if (_statusLabel == nil) {
        _statusLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.width-200)/2.0, self.statusButton.bottom+10, 200, 15)];
        _statusLabel.textAlignment = NSTextAlignmentCenter;
        _statusLabel.text = @"添加银行卡";
        _statusLabel.font = [UIFont systemFontOfSize:15.0];
        _statusLabel.textColor = UIColorFromRGB(0x2d2d2d);
    }
    return _statusLabel;
}

- (UILabel *)desLabel
{
    if (_desLabel == nil) {
        _desLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.width-200)/2.0, self.statusLabel.bottom+5, 200, 11)];
        _desLabel.textAlignment = NSTextAlignmentCenter;
        _desLabel.text = @"(用以收取佣金)";
        _desLabel.font = [UIFont systemFontOfSize:11.0];
        _desLabel.textColor = UIColorFromRGB(0x999999);
    }
    return _desLabel;

}

- (UITapGestureRecognizer *)tapGesture
{
    if (_tapGesture == nil) {
        _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
    }
    return _tapGesture;
}




@end
